import requests,re

def get_sc():
    base_url = 'http://www.zjmazhang.gov.cn/hdjlpt/published?via=pc'
    resp = requests.get(base_url)
    html = resp.content.decode('utf8')
    base_cookie = resp.cookies

    session = base_cookie['szxx_session']
    csrf = re.findall(r"var _CSRF = '(.*)';",html)

    return session,csrf[0]

def get_data(szxx_session,csrf):

    url = 'http://www.zjmazhang.gov.cn/hdjlpt/letter/pubList'
    headers = {
        'Cookie':'szxx_session={}'.format(szxx_session),
        'X-CSRF-TOKEN':csrf
    }
    data = {
        'offset': 0,
        'limit': 20,
        'site_id': '759010'
    }
    response = requests.post(url,headers = headers,data = data)
    data = response.json()['data']['list']
    print(data)

if __name__ == '__main__':
    szxx_session,csrf = get_sc()
    get_data(szxx_session,csrf)